import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout/index.vue'
import {
  getToken,
  setToken,
  removeToken,
  getStoreId,
  setStoreId,
  removeStoreId,
  setUserInfo,
  getUserInfo,
  removeUserInfo
} from '@/utils/cookies'
import store from '@/store'
import Cookies from 'js-cookie'
import { UserModule } from '@/store/modules/user'

Vue.use(Router)

// // 公共路由
// export const constantRoutes = [
//   {
//     path: '/redirect',
//     component: Layout,
//     hidden: true,
//     children: [
//       {
//         path: '/redirect/:path(.*)',
//         component: () => import('@/views/redirect.vue')
//       }
//     ]
//   },
//   {
//     path: '/login',
//     component: () =>
//       import(/* webpackChunkName: "login" */ '@/views/login/index.vue'),
//     meta: { title: '苍穹外卖', hidden: true, notNeedAuth: true }
//   },
//   {
//     path: '/404',
//     component: () => import(/* webpackChunkName: "404" */ '@/views/404.vue'),
//     meta: { title: '苍穹外卖', hidden: true, notNeedAuth: true }
//   },
//   {
//     path: '*',
//     redirect: '/404',
//     meta: { hidden: true }
//   }
// ]

// 动态路由，基于用户权限动态去加载
export const dynamicRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: 'home',
        component: () =>
          import(
            /* webpackChunkName: "dashboard" */ '@/views/home/index.vue'
          ),
        name: 'Home',
        meta: {
          title: 'z',
          icon: 'dashboard',
          affix: true,
        }
      },
      {
        path: '/statistics',
        component: () =>
          import(
            /* webpackChunkName: "shopTable" */ '@/views/statistics/index.vue'
          ),
        meta: {
          title: '数据统计',
          icon: 'icon-statistics'
        }
      },
      {
        path: '/caseRec',
        component: () =>
          import(
            /* webpackChunkName: "shopTable" */ '@/views/caseRec/index.vue'
          ),
        meta: {
          title: '案例推荐',
          icon: 'icon-combo'
        }
      },
      {
        path: '/case',
        component: () =>
          import(
            /* webpackChunkName: "shopTable" */ '@/views/case/index.vue'
          ),
        meta: {
          title: '案例管理',
          icon: 'icon-order'
        }
      },
      {
        path: '/caseRec/face',
        component: () =>
          import(
            /* webpackChunkName: "shopTable" */ '@/views/caseRec/face.vue'
          ),
        meta: {
          title: '人脸比对',
          hidden: true
        }
      },
      // {
      //   path: 'order',
      //   component: () =>
      //     import(
      //       /* webpackChunkName: "shopTable" */ '@/views/orderDetails/index.vue'
      //     ),
      //   meta: {
      //     title: '订单管理',
      //     icon: 'icon-order'
      //   }
      // },
      // {
      //   path: 'setmeal',
      //   component: () =>
      //     import(
      //       /* webpackChunkName: "shopTable" */ '@/views/setmeal/index.vue'
      //     ),
      //   meta: {
      //     title: '套餐管理',
      //     icon: 'icon-combo'
      //   }
      // },
      // {
      //   path: 'dish',
      //   component: () =>
      //     import(
      //       /* webpackChunkName: "shopTable" */ '@/views/dish/index.vue'
      //     ),
      //   meta: {
      //     title: '菜品管理',
      //     icon: 'icon-dish'
      //   }
      // },
      // {
      //   path: '/dish/add',
      //   component: () =>
      //     import(
      //       /* webpackChunkName: "shopTable" */ '@/views/dish/addDishtype.vue'
      //     ),
      //   meta: {
      //     title: '添加菜品',
      //     hidden: true
      //   }
      // },

      // {
      //   path: 'category',
      //   component: () =>
      //     import(
      //       /* webpackChunkName: "shopTable" */ '@/views/category/index.vue'
      //     ),
      //   meta: {
      //     title: '分类管理',
      //     icon: 'icon-category'
      //   }
      // },
      {
        path: 'employee',
        component: () =>
          import(
            /* webpackChunkName: "shopTable" */ '@/views/employee/index.vue'
          ),
        meta: {
          title: '学生管理',
          icon: 'icon-employee'
        }
      },

      {
        path: '/employee/add',
        component: () =>
          import(
            /* webpackChunkName: "dashboard" */ '@/views/employee/addEmployee.vue'
          ),
        meta: {
          title: '添加学生',
          hidden: true
        }
      },

      // {
      //   path: '/setmeal/add',
      //   component: () =>
      //     import(
      //       /* webpackChunkName: "shopTable" */ '@/views/setmeal/addSetmeal.vue'
      //     ),
      //   meta: {
      //     title: '添加套餐',
      //     hidden: true
      //   }
      // },

      {
        path: '/case/add',
        component: () =>
          import(
            /* webpackChunkName: "shopTable" */ '@/views/case/addCase.vue'
          ),
        meta: {
          title: '添加案例',
          hidden: true
        }
      }
    ]
  },
]

const router = new Router({
  scrollBehavior: (to, from, savedPosition) => {
    if (savedPosition) {
      return savedPosition
    }
    return { x: 0, y: 0 }
  },
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/login',
      component: () =>
        import(/* webpackChunkName: "login" */ '@/views/login/index.vue'),
      meta: { title: '贪吃の🐍', hidden: true, notNeedAuth: true}
    },
    {
      path: '/404',
      component: () => import(/* webpackChunkName: "404" */ '@/views/404.vue'),
      meta: { title: '贪吃の🐍', hidden: true, notNeedAuth: true}
    },
    {
      path: '/',
      component: Layout,
      redirect: '/home',
      children: [
        {
          path: 'home',
          component: () =>
            import(
              /* webpackChunkName: "dashboard" */ '@/views/home/index.vue'
            ),
          name: 'home',
          meta: {
            title: '主页',
            icon: 'dashboard',
            affix: true,
          }
        },
        // {
        //   path: '/statistics',
        //   component: () =>
        //     import(
        //       /* webpackChunkName: "shopTable" */ '@/views/statistics/index.vue'
        //     ),
        //   meta: {
        //     title: '数据统计',
        //     icon: 'icon-statistics'
        //   }
        // },
        {
          path: '/caseRec',
          component: () =>
            import(
              /* webpackChunkName: "shopTable" */ '@/views/caseRec/index.vue'
            ),
          meta: {
            title: '案例推荐',
            icon: 'icon-combo',
          }
        },
        {
          path: '/case',
          component: () =>
            import(
              /* webpackChunkName: "shopTable" */ '@/views/case/index.vue'
            ),
          meta: {
            title: '案例管理',
            icon: 'icon-order',
            notNeedAuth: false
          }
        },
        {
          path: '/gameRec',
          component: () =>
            import(
              /* webpackChunkName: "shopTable" */ '@/views/gameRec/index.vue'
            ),
          meta: {
            title: '游戏推荐',
            icon: 'icon-combo',
          }
        },
        {
          path: '/game/slither01',
          component: () =>
            import(
              /* webpackChunkName: "shopTable" */ '@/views/game/slither-01.vue'
            ),
          meta: {
            title: '经典蛇',
            hidden: true,
            notNeedAuth: false
          }
        },
        {
          path: '/game/slither02',
          component: () =>
            import(
              /* webpackChunkName: "shopTable" */ '@/views/game/slither-02.vue'
            ),
          meta: {
            title: '像素蛇',
            hidden: true,
            notNeedAuth: false
          }
        },
        {
          path: '/about',
          component: () =>
            import(
              /* webpackChunkName: "shopTable" */ '@/views/about/index.vue'
            ),
          meta: {
            title: '资助我们',
            icon: 'icon-order',
            notNeedAuth: false
          }
        },
        {
          path: '/contact',
          component: () =>
            import(
              /* webpackChunkName: "shopTable" */ '@/views/contact/index.vue'
            ),
          meta: {
            title: '联系我们',
            icon: 'icon-order',
            notNeedAuth: false
          }
        },
        {
          path: '/caseRec/face',
          component: () =>
            import(
              /* webpackChunkName: "shopTable" */ '@/views/caseRec/face.vue'
            ),
          meta: {
            title: '人脸比对',
            hidden: true,
            notNeedAuth: false
          }
        },
        // {
        //   path: 'order',
        //   component: () =>
        //     import(
        //       /* webpackChunkName: "shopTable" */ '@/views/orderDetails/index.vue'
        //     ),
        //   meta: {
        //     title: '订单管理',
        //     icon: 'icon-order'
        //   }
        // },
        // {
        //   path: 'setmeal',
        //   component: () =>
        //     import(
        //       /* webpackChunkName: "shopTable" */ '@/views/setmeal/index.vue'
        //     ),
        //   meta: {
        //     title: '套餐管理',
        //     icon: 'icon-combo'
        //   }
        // },
        // {
        //   path: 'dish',
        //   component: () =>
        //     import(
        //       /* webpackChunkName: "shopTable" */ '@/views/dish/index.vue'
        //     ),
        //   meta: {
        //     title: '菜品管理',
        //     icon: 'icon-dish'
        //   }
        // },
        // {
        //   path: '/dish/add',
        //   component: () =>
        //     import(
        //       /* webpackChunkName: "shopTable" */ '@/views/dish/addDishtype.vue'
        //     ),
        //   meta: {
        //     title: '添加菜品',
        //     hidden: true
        //   }
        // },

        // {
        //   path: 'category',
        //   component: () =>
        //     import(
        //       /* webpackChunkName: "shopTable" */ '@/views/category/index.vue'
        //     ),
        //   meta: {
        //     title: '分类管理',
        //     icon: 'icon-category'
        //   }
        // },
        {
          path: 'employee',
          component: () =>
            import(
              /* webpackChunkName: "shopTable" */ '@/views/employee/index.vue'
            ),
          meta: {
            title: '学生管理',
            icon: 'icon-employee',
            notNeedAuth: false
          }
        },

        {
          path: '/employee/add',
          component: () =>
            import(
              /* webpackChunkName: "dashboard" */ '@/views/employee/addEmployee.vue'
            ),
          meta: {
            title: '添加学生',
            hidden: true,
            notNeedAuth: false
          }
        },

        // {
        //   path: '/setmeal/add',
        //   component: () =>
        //     import(
        //       /* webpackChunkName: "shopTable" */ '@/views/setmeal/addSetmeal.vue'
        //     ),
        //   meta: {
        //     title: '添加套餐',
        //     hidden: true
        //   }
        // },

        {
          path: '/case/add',
          component: () =>
            import(
              /* webpackChunkName: "shopTable" */ '@/views/case/addCase.vue'
            ),
          meta: {
            title: '添加案例',
            hidden: true,
            notNeedAuth: false
          }
        }
      ]
    },
    {
      path: '*',
      redirect: '/404',
      meta: { hidden: true }
    }
  ]
})

export default router
